/** * dmcss-wp login form (javascript/jQuery) * * Javascript & jQuery to implement tabbed login form and toggle visibility of UI elements * * @author Asentech * @uses jQuery */ (function($) { $(document).ready(function() { // Toggle between active tabs $( '#dmcss_tabs li a' ).click( function ( $event ) { $event.preventDefault(); $( 'div.active_tab' ).hide(); $( '.active_tab' ).removeClass( 'active_tab' ); $parent = $event.target.id.replace( 'link', 'tab' ); $tab = $event.target.id.replace( 'link', 'div' ); $( '#' + $parent ).addClass( 'active_tab' ); $( '#' + $tab ).addClass( 'active_tab' ); $( 'div.active_tab' ).show(); }); // Un-hide default tab $( '.dmcss_tab_div.active_tab' ).show(); // Disable inputs if we're previewing $( '#form_tabs input.disabled' ).attr( 'disabled', 'disabled' ); //Login Form Validation $(".loginform #omeda-submit").on('click', function(e){ e.preventDefault(); var userId = $("#omeda_name").val(); var password = $("#omeda_password").val(); var tecnaviaLogin = $(".login_red").val(); var error = 0; var errorMsg = ''; var last_visited_article = $(".loginform .last_visited_article").val(); if(userId == ''){ errorMsg += '
  • Please enter user id/email address.
  • '; error = 1; } if (password == ''){ errorMsg += '
  • Please enter password.
  • '; error = 1; } if(error == 1){ $(".omeda_login_form .errorbox").html('

    Error:

    '); $(".omeda_login_form .errorbox").addClass('visible'); return false; } else { $(".omeda_login_form .errorbox").removeClass('visible'); $(".omeda_login_form .errorbox").html(); $(".loginform .formbtnloader #loading-image").show(); $.ajax({ url: dmcss_ajax_object.ajax_url, type: 'POST', data: { 'action': 'validate_omeda_login', 'username': userId, 'password': password, 'tecnaviaLogin': tecnaviaLogin, 'last_visited_article': last_visited_article }, success: function(response){ $(".loginform .formbtnloader #loading-image").hide(); if(response){ var result = $.parseJSON(response); if(result.status == 'failed'){ $(".omeda_login_form .errorbox").html(result.message); $(".omeda_login_form .errorbox").addClass('visible'); return false; } if(result.status == 'success'){ $(".omeda_login_form .successbox").html(result.message); $(".omeda_login_form .successbox").addClass('visible'); setTimeout(function(){ window.location.href = result.redirect_url }, 2000); } if(result.status == '2fa_pending'){ $(".omeda_login_form .successbox").html(result.message); $(".omeda_login_form .successbox").addClass('visible'); setTimeout(function(){ window.location.href = result.redirect_url }, 2000); } } else { $(".omeda_login_form .errorbox").html('

    ERROR: Failed to send request!

    '); $(".omeda_login_form .errorbox").addClass('visible'); return false; } } }); } }); }); })(jQuery); jQuery(document).ready(function() { if(jQuery(".loginform").length > 0){ if(jQuery(".loginform .last_visited_article").length > 0){ var last_article_link = localStorage.getItem('_last_visited_article_url'); if(last_article_link != ''){ jQuery(".loginform .last_visited_article").val(last_article_link); } } } });